package ch08_Swing高级组件;

import ch07_GUI编程.BaseFrame;
import ch07_GUI编程.ImageFactory;

import javax.swing.*;

public class JOptionPaneDemo {
	public static void main(String[] args) {
		BaseFrame f = new BaseFrame("JOptionPane Demo");
		ImageIcon icon = ImageFactory.create("qq1.png");
		String[] btnsText = {"好，删除！","不，以后再说。"};		//按钮文字
		String[] groups = {"同事","家人","同学"};				//下拉列表文字

		//消息对话框
		JOptionPane.showMessageDialog(f, "邮件发送失败。","发送邮件",JOptionPane.ERROR_MESSAGE);

		//消息对话框（自定义图标）
		JOptionPane.showMessageDialog(f, "收到一封新邮件。","收到邮件",JOptionPane.INFORMATION_MESSAGE,icon);

		//确认对话框
		JOptionPane.showConfirmDialog(f, "确认要删除该邮件吗？","删除邮件",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE);

		//选项对话框（自定义按钮文字）
		JOptionPane.showOptionDialog(f,"确认要删除该邮件吗？","删除邮件",JOptionPane.YES_NO_CANCEL_OPTION,JOptionPane.QUESTION_MESSAGE,null,btnsText,btnsText[1]);

		//输入对话框（文本框）
		JOptionPane.showInputDialog(f,"请输入收件人地址：","name@gmail.com");

		//输入对话框（下拉列表）
		JOptionPane.showInputDialog(f,"请输入联系人分类：","选择分类",JOptionPane.PLAIN_MESSAGE,null,groups,groups[1]);

		f.showMe();

	}
}
